package atom.core0.util.tree;

import java.util.TreeSet;

public class MyBaseNode implements INode, Comparable
{
	private String	id;
	private String	name;

	private TreeSet<INode>	son;


	public String getId()
	{
		return id;
	}

	public void setId(String id)
	{
		this.id = id;
	}


	public String getName()
    {
    	return name;
    }

	public void setName(String name)
    {
    	this.name = name;
    }


	public TreeSet<INode> getSon()
    {
    	return son;
    }

	/**
	 * 父级节点编号.
	 * 
	 * @return
	 */
	public String getParent()
	{
		if (id.length() > 3)
			return id.substring(0, id.length() - 3);
		return "";
	}

	public void addSon(INode node)
	{
		if (son == null)
			son = new TreeSet();
		son.add(node);
	}

	public int compareTo(Object o)
	{
		MyBaseNode other = (MyBaseNode) o;

		// 先按照name属性排序
		if (this.id.compareTo(other.getId()) > 0)
			return 1;
		if (this.id.compareTo(other.getId()) < 0)
			return -1;


		return 0;
	}
}
